/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.mts.client.core.view;

import com.intelligent.mts.client.listener.StatusBarListener;
import com.intelligent.mts.client.utils.EventBusUtils;
import com.intelligent.mts.client.utils.GBC;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.swing.*;
import java.awt.*;

/**
 * Created by cherry on 2016/7/25.
 */
@Component
public class MainStatusPanel extends JPanel {
    private final static String EMPTY_VALUE = "";

    @PostConstruct
    private void initComponents() {
        EventBusUtils.register(new StatusBarListener());

        lblMsg = new JLabel();


        this.setLayout(new GridBagLayout());
        this.add(lblMsg, new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100).setInsets(4));
    }

    public void setStatusValue(String value) {
        lblMsg.setText(value);
    }

    public void setStatusValue(String value, Color color) {
        if(color != null) {
            lblMsg.setForeground(color);
        }
        lblMsg.setText(value);
        lblMsg.setForeground(color);
    }

    public void cleanStatusValue() {
        lblMsg.setText(EMPTY_VALUE);
    }


    private JLabel lblMsg;
}
